{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "5f2a8c9d-2e06-4216-b34c-30a95f2c6e87",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[ 0.3643, -0.3553,  0.3399, -1.1419,  0.6973, -0.3624,  1.1248, -0.9044,\n",
      "          0.3053, -0.6222,  1.3312,  2.1093,  0.3474,  1.5123, -0.9907,  1.4324,\n",
      "          0.7039, -0.3389, -0.1721, -0.3323],\n",
      "        [ 0.4705,  0.3009, -1.5860,  0.5909, -1.6528, -0.7929,  0.9897,  0.6687,\n",
      "          0.7301, -0.3481, -1.1485, -0.2888, -0.9335,  0.3397,  0.0649, -0.6975,\n",
      "          0.1814, -1.3601,  0.9489, -1.1590],\n",
      "        [ 0.1388, -1.3799,  1.1883, -0.3050, -1.0039, -0.0561,  0.3517,  0.5018,\n",
      "         -1.5251, -2.2142,  0.4029, -1.4801, -0.7418, -0.6892, -0.3788, -0.3929,\n",
      "          0.0621,  1.6091,  0.5286, -1.6321],\n",
      "        [-0.7410,  0.9436,  1.7672,  1.8318,  0.2839,  1.5397, -0.6284,  1.1335,\n",
      "          0.7825,  0.2213,  1.2155, -1.0363,  1.3819,  0.1051, -1.4866, -1.0951,\n",
      "          0.5084, -0.2523, -0.6634,  0.4551],\n",
      "        [ 0.5547, -1.4633, -0.2787, -0.6546,  0.7170,  0.6624, -0.0798, -2.5789,\n",
      "         -2.0624,  0.2059, -0.4638,  0.8981,  0.8267,  0.3079,  0.6906, -1.2916,\n",
      "         -1.5526,  0.9273, -1.4954, -1.3379],\n",
      "        [-2.3741,  1.2929, -0.8622,  0.0311,  1.8224,  0.5283,  1.2181,  0.2128,\n",
      "          1.3731,  0.8543, -0.0477,  0.0087,  0.0179, -1.8311,  1.7118, -0.0156,\n",
      "          0.4942, -0.8938,  0.1834,  1.2504],\n",
      "        [ 1.1884, -1.2466,  0.3795,  1.7059, -0.4867, -0.4093, -0.3109,  0.2644,\n",
      "         -0.1500, -0.6948, -0.7545, -0.2324,  1.2965, -1.2375, -0.9640,  0.8142,\n",
      "         -2.1545, -1.5495,  2.2677,  0.1933],\n",
      "        [ 0.3080,  0.9531, -1.0482, -0.4495,  0.4714, -1.5609,  0.2526, -0.1760,\n",
      "          0.3328,  0.5111, -0.7222, -0.0837, -0.9278,  1.4244,  0.9028,  1.1904,\n",
      "          1.3419,  0.5040, -0.7241,  0.7713],\n",
      "        [-0.8555,  0.1183,  0.6686, -0.9816,  0.2966, -1.0863, -0.6436,  0.5275,\n",
      "          0.3716,  1.6939, -1.3105,  0.8679,  0.4887, -0.1905,  1.0640,  1.1135,\n",
      "          0.3216,  0.4021, -0.3105,  0.6895],\n",
      "        [ 0.9457,  0.8362, -0.5684, -0.6271, -1.1451,  1.5374, -2.2741,  0.3507,\n",
      "         -0.1580,  0.3927,  1.4977, -0.7627, -1.7560,  0.2589, -0.6140, -1.0579,\n",
      "          0.0937,  0.9523, -0.5631,  1.1018]],\n",
      "       grad_fn=<NativeBatchNormBackward>)\n"
     ]
    }
   ],
   "source": [
    "import torch\n",
    "import torch.nn as nn\n",
    "import numpy as np\n",
    "\n",
    "# 将数据归一化, 维度的增加使区间扩大\n",
    "length = 20\n",
    "m = nn.BatchNorm1d(length)\n",
    "# m = nn.BatchNorm1d(100, affine=False)\n",
    "input = torch.randn(10, length)\n",
    "output = m(input)\n",
    "print(output)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "a589189e-f7a8-484e-bd2d-e40b920a3c5b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[[3.4746],\n",
      "         [2.9189],\n",
      "         [3.7668],\n",
      "         [3.1812]]])\n"
     ]
    }
   ],
   "source": [
    "# target output size of 5\n",
    "m = nn.AdaptiveMaxPool1d(1)\n",
    "input = torch.randn(1, 4, 1000)\n",
    "output = m(input)\n",
    "print(output)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c78ed828-ae46-4c19-b26c-7b07c772e4c3",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
